package cn.itcast.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <h4>day01_1_springcloud_eureka</h4>
 * <p>交换机 </p>
 *
 * @author : by wujianming
 * @date : 2021-11-24 19:39
 **/
@Configuration
public class FanoutConfig {

    //FanoutExchange：广播模式交换机
    @Bean
    public FanoutExchange fanoutExchange(){
       return new FanoutExchange("itcast.fanout");
    }

    //创建队列Queue
    @Bean
    public Queue fanoutQueue() {
        return new Queue("fanout.queue1");
    }

    //绑定交换机和队列
    @Bean
    public Binding fanoutBinding() {
        return BindingBuilder.bind(fanoutQueue()).to(fanoutExchange());
    }

    //第二个队列
    @Bean
    public Queue fanoutQueue2() {
        return new Queue("fanout.queue2");
    }
    //绑定交换机和第二个队列
    @Bean
    public Binding fanoutBinding2() {
        return BindingBuilder.bind(fanoutQueue2()).to(fanoutExchange());
    }


}
